var provinces = new Array("京","沪","浙","苏","粤","鲁","晋","冀",
            "豫","川","渝","辽","吉","黑","皖","鄂",
            "津","贵","云","桂","琼","青","新","藏",
            "蒙","宁","甘","陕","闽","赣","湘");

var keyNums = new Array(
            "Q","W","E","R","T","Y","U","I","O","P",
            "A","S","D","F","G","H","J","K","L",
            "Z","X","C","V","B","N","M");
var next=0;			
	function showProvince(){
	
			$("#pro").html("");
			var ss="";
			for(var i=0;i<provinces.length-4;i++){
				ss=ss+addKeyProvince(i)
			} 
			$("#pro").html("<ul class='clearfix ul_pro'>"+ss+"</ul>");
			ss="";
			for(var i=provinces.length-4;i<provinces.length;i++){
				ss=ss+addKeyProvince(i)
			} 
			$("#pro").append("<ul class='clearfix ul_pro' style='margin:0;width:100%;padding:0;padding-bottom:2px;display:flex;justify-content:center'>"+ss+"</ul>");
	} 
	function showKeybord(){
		
			$("#pro").html("");
			var sss="";
			for(var i=0;i<keyNums.length;i++){
				sss=sss+'<li class="ikey ikey'+i+' '+(i>9?"li_zm":"li_num")+' '+(i>28?"li_w":"")+'" ><span onclick="choosekey(this,'+i+');">'+keyNums[i]+'</span></li>'
			} 
			$("#pro").html("<ul class='clearfix ul_keybord'>"+sss+"</ul>");
	}
    function addKeyProvince(provinceIds){
        var addHtml = '<li>';
            addHtml += '<span onclick="chooseProvince(this);">'+provinces[provinceIds]+'</span>';
            addHtml += '</li>';
            return addHtml;
    }

    function chooseProvince(obj){
       $(".city").text($(obj).text());     
	   closePro()
	}	
	
	
	function choosekey(obj,jj){	
			$('.city_num').text($(obj).text());
			closePro();
	       
	}
	
	function closePro(){
       layer.closeAll()
	}		
//	function cleanPro(){
//     $(".ul_input").find("span").text("");
//     getval()
//     $(".hasPro").removeClass("hasPro");
//     $(".ppHas").removeClass("ppHas");
//	   next=0;
//	}	
	function trimStr(str){return str.replace(/(^\s*)|(\s*$)/g,"");}
	function getpai(){
		var pai=trimStr($(".car_input").text());
		$(".car_input").attr("data-pai",pai);
	}
	
//	function getval(){
//		var list = $('.ul_input li span');
//		var data ='';
//		for(var i=0;i<list.length;i++){
//			data += $(list[i]).text();
//		}
//		$("input[name='car']").val(data);
//		console.log($("input[name='car']").val())
//	}
window.onload = function() {

	$(".city").click(function(){
		closePro();
		 layer.open({
			type: 1
			,content: '<div id="close_keyboard"><span class="close" onclick="closePro()">关闭</span></div><div id="pro"></div>'
			,anim: 'up'
			,shade :false 
			,style: 'position:fixed; bottom:0; left:0; width: 100%; height: auto; padding:0; border:none;'
		  });
		 showProvince()
	})
	$(".city_num").click(function(){
		 // 如果已选择省份
		 closePro();
			 layer.open({
				type: 1
				,content: '<div id="close_keyboard"><span class="close" onclick="closePro()">关闭</span></div><div id="pro"></div>'
				,anim: 'up'
				,shade :false 
				,style: 'position:fixed; bottom:0; left:0; width: 100%; height: auto; padding:0; border:none;'
			  });
			 showKeybord()
	})
	

}
